package com.sxz.sbs.module.client.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sxz.sbs.R;
import com.sxz.sbs.app.GlideApp;

import java.util.List;


/**
 * Created by tian on 2018/1/26 0026.
 */

public class EvidenceAdapter extends BaseQuickAdapter<String,BaseViewHolder>{
    private int imageSize;
    public EvidenceAdapter(Context context,@Nullable List<String> data) {
        super(R.layout.item_evidence_layout,data);
        setColumnNumber(context,3);
    }
    private void setColumnNumber(Context context, int i) {
        WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        DisplayMetrics metrics = new DisplayMetrics();
        wm.getDefaultDisplay().getMetrics(metrics);
        int widthPixels = metrics.widthPixels;
        imageSize = widthPixels / i;
    }
    @Override
    protected void convert(BaseViewHolder helper, String item) {
        GlideApp.with(mContext).load(item).override(imageSize, imageSize).placeholder(R.drawable.icon_place_holder).
                into((ImageView) helper.getView(R.id.iv_evidence));
    }
}
